//
// Copyright (c) 2009 All Right Reserved
//
// vl
//
// 2009-01-01
// Contains ...
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Text;
using System.Xml.Linq;
using JetBrains.Annotations;
using LargoCommon.Abstract;
namespace LargoCommon.Music
{
///
/// Instrument Change.
///
public sealed class TempoChange : AbstractChange {
#region Constructors
///
/// Initializes a new instance of the class.
///
[UsedImplicitly]
public TempoChange() {
}
///
/// Initializes a new instance of the class.
///
/// The given change.
public TempoChange(XElement xchange)
: base(xchange) {
Contract.Requires(xchange != null);
//// if (xchange == null) { return; }
this.TempoNumber = XmlSupport.ReadByteAttribute(xchange.Attribute("TempoNumber"));
this.ChangeType = MusicalChangeType.Tempo;
}
///
/// Initializes a new instance of the class.
///
/// The given bar.
public TempoChange(int givenBar)
: base(givenBar, 0, MusicalChangeType.Tempo) {
}
#endregion
#region Properties - Xml
///
/// Gets Xml representation.
///
///
/// Property description.
///
public override XElement GetXElement {
get {
var change = base.GetXElement;
change.Add(new XAttribute("TempoNumber", this.TempoNumber));
return change;
}
}
#endregion
#region Properties
/// Gets or sets class of melodic part.
/// Property description.
public int TempoNumber { get; set; }
///
/// Gets InstrumentString.
///
/// General musical property.
//// Do not make private!!! - It is used by DetailMusicalChanges.xaml.
[UsedImplicitly]
public string TempoString => string.Format(CultureInfo.InvariantCulture, "{0} {1}", this.TempoNumber.ToString(CultureInfo.CurrentCulture), MusicalProperties.GetTempoValue(this.TempoNumber));
#endregion
#region Public methods
///
/// Clones this instance.
///
/// Returns object.
public override object Clone() {
var tmc = new TempoChange(this.BarNumber) { TempoNumber = this.TempoNumber };
//// tmc.BlockModel = this.BlockModel;
return tmc;
}
#endregion
#region String representation
/// String representation of the object.
/// Returns value.
public override string ToString() {
var s = new StringBuilder();
s.AppendFormat(CultureInfo.CurrentCulture, base.ToString());
s.Append(", " + this.TempoString);
return s.ToString();
}
#endregion
}
}